// $Id$
// Licensed under Apache License Version 2.0
// See: http://www.apache.org/licenses/LICENSE-2.0.html
package de.servicezombie.tcmdb.dao.mongo;

import org.springframework.data.mongodb.core.query.Criteria;

public class MongoUtils {
	
	public static String toString(Criteria criteria) {
		if(criteria == null) {
			return null;
		}
		
		/* TODO chained criteria might not work */
		StringBuilder sb = new StringBuilder();
		sb.append(criteria.getClass().getSimpleName())
			.append(" [")
			.append(criteria.getCriteriaObject())
			.append("]");
		
		return sb.toString();
	}

	public static void invalidateId(MongoDomainObject object) {
		object.setId(null);
		object.setRevision(null);
	}

}
